﻿<html>
<head>
    <title></title>
    <div id="themefile"></div>
    <style>
        @import "this://app/images/public.css";
        @import "images/form.css";
        html{background:color(center-background-color)}
        body{width:*; height:max-content; overflow:hidden;margin:0;padding:0;font-size:12dip}
        .input_wrapper{flow:row(label,input);}
        h4{margin:7dip 0}
        textarea{color:color(general-text-color);size:*;height:500dip;padding:5dip;width:*;border:0;overflow:scroll-indicator;white-space:pre-wrap;word-wrap:break-word;word-break:break-all}
    </style>

</head>
<body>
    <div class="input_wrapper">
        <textarea id="doc"></textarea>
        <div class="form_bottom">
        <button class="cancel" id="delete">{{Delete}}</button>
        <button class="ok" id="update">{{Update}}</button>
        </div>
        </div>
    
    <script type="text/tiscript">
        include ROOTPATH + "tis/utils.tis";

        //初始化主题
        initUiTheme();
        
        //创建语言
        createLang();
 
        view.root.on("ready", function(){
            view.windowCaption =  CONF.Lang.EditDoc;
            var docContent = mainView.GetGameDoc("doc",view.parameters.id);
            docContent = docContent.replace("<br>","\n");
            docContent = docContent.trim();
            $(#doc).value = docContent;
        });

        //更新文档
        event click $(#update){
            var docContent = $(#doc).value;
            if (docContent != ""){
                docContent = docContent.trim();
                mainView.SetGameDoc("doc",view.parameters.id,docContent);
                alert(CONF.Lang.UpdateSuccess);
            }else{
                alert(CONF.Lang.ContentIsNotEmpty);
            }
        }

        //删除文档
        event click $(#delete){
            var result = view.msgbox {
                type:#warning, 
                content:CONF.Lang.DeleteDocConfirm, 
                caption:CONF.Lang.DeleteDoc,
                buttons:[
                    {id:#yes,text:CONF.Lang.Delete},
                    {id:#cancel,text:CONF.Lang.Cancel,role:"default-button"}
                ]
            };
            if (result != "yes"){
                return true;
            }
            mainView.DelGameDoc("doc",view.parameters.id);
            alert(CONF.Lang.DeleteSuccess);
            view.close();
        }
    </script>
</body>
</html>
